noremap s <leader><leader>/
noremap <LEADER>pp zR<Esc>/>++><CR>:nohlsearch<CR>"84x<Left>p

" u 是撤销，大写的U是反撤销，符合直觉
noremap U <C-r>

" 大写方向键回到句首，或者移动多行
noremap H ^
noremap L $
nnoremap J 10j
vnoremap J 3j
nnoremap K 10k
vnoremap K 3k

" noremap <A-e> <nop>

" Alt + shift + direction to jump cursor between windows
noremap <A-L> <C-w><Right>
noremap <A-H> <C-w><Left>
noremap <A-J> <C-w><Down>
noremap <A-K> <C-w><Up>


noremap b B
noremap B b
noremap w W
noremap W w
noremap ]p p
noremap p ]p
noremap <LEADER>ay ggyG
noremap <LEADER>ad ggdG
noremap <LEADER>ap ggVGP
noremap <LEADER>qn @n
noremap qq @n
noremap <LEADER>e :e!<CR>
noremap <M-f> /
" noremap  <LEADER><LEADER> :set nocursorcolumn<CR>:nohl<CR>
noremap <LEADER><LEADER> <Esc>/>++><CR>:nohlsearch<CR>c4l
noremap <LEADER>ll :set cursorcolumn<CR>
noremap <M--> <C-o>
noremap <M-=> <C-i>
cnoremap <M-f> /
noremap s <nop>
inoremap <M-o> <nop>
" inoremap <M-e> <nop>
" noremap si :set splitright<CR>:vsplit<CR>
" noremap sn :set nospr<CR>:vsplit<CR>
" noremap se :set splitbelow<CR>:split<CR>
" noremap su :set nosplitbelow<CR>:split<CR>
noremap <LEADER>ta :tabe<CR>

nnoremap <Esc> <Esc>:nohl<cr>
" nnoremap ciw ciw
nnoremap <up> :res +5<CR>
nnoremap <down> :res -5<CR>
nnoremap <left> :vertical resize -5<CR>
nnoremap <right> :vertical resize +5<CR>
nnoremap <M-q> :q!<CR>
nnoremap <M-w> :w<CR>
" nnoremap  <M-t> :CocCommand explorer<CR>
noremap <LEADER>ww :w !sudo tee %<CR>
noremap ? *
noremap!  <Esc>
nnoremap > >>
nnoremap < <<
" fold and unfold {{{
noremap <LEADER>o za
noremap <LEADER>zf :call Fold()<CR>
function! Fold()
    if &filetype=='cpp'
        exec 'normal! zfa{'
    else
        exec 'normal! zfip'
    endif
endfunction
" }}}

" markdown shortcut key {{{
autocmd Filetype markdown inoremap <buffer> ;, <++>
autocmd Filetype markdown inoremap <buffer> ;f <Esc>/<++><CR>:nohlsearch<CR>c4l
autocmd Filetype markdown nnoremap <buffer> ;f <Esc>/<++><CR>:nohlsearch<CR>c4l
autocmd Filetype markdown inoremap <buffer> ;s <Esc>/ <++><CR>:nohlsearch<CR>c5l
autocmd Filetype markdown inoremap <buffer> ;- ---<Enter><Enter>
autocmd Filetype markdown inoremap <buffer> ;b **** <++><Esc>F*hi
autocmd Filetype markdown inoremap <buffer> ;x ~~~~ <++><Esc>F~hi
autocmd Filetype markdown inoremap <buffer> ;x ** <++><Esc>F*i
autocmd Filetype markdown inoremap <buffer> ;q `` <++><Esc>F`i
autocmd Filetype markdown inoremap <buffer> ;c ```<Enter><++><Enter>```<Enter><Enter><++><Esc>4kA
autocmd Filetype markdown inoremap <buffer> ;g - [ ] <Enter><++><ESC>kA
autocmd Filetype markdown inoremap <buffer> ;u <u></u><++><Esc>F/hi
autocmd Filetype markdown inoremap <buffer> ;p ![](<++>) <Enter><++><Esc>kF[a
autocmd Filetype markdown inoremap <buffer> ;a [](<++>) <++><Esc>F[a
autocmd Filetype markdown inoremap <buffer> ;1 #<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> ;2 ##<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> ;3 ###<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> ;4 ####<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> ;t <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
" }}}

" register yank and paste {{{
noremap <LEADER>pn "np
noremap <LEADER>pe "ep
noremap <LEADER>pi "ip
vnoremap <LEADER>yn "ny
vnoremap <LEADER>ye "ey
vnoremap <LEADER>yi "iy
vnoremap  <Esc>
" }}}

" number key {{{
" noremap! tna 1
" noremap! tnr 2
" noremap! tns 3
" noremap! tnt 4
" noremap! tnd 5
" noremap! tnh 6
" noremap! tnn 7
" noremap! tne 8
" noremap! tni 9
" noremap! tno 0
" noremap! tnA !
" noremap! tnR @
" noremap! tnS #
" noremap! tnT $
" noremap! tnD %
" noremap! tnH ^
" noremap! tnN &
" noremap! tnE *
" noremap! tnI (
" noremap! tnO )
inoremap ,fj >++>
" noremap! tn<Enter> \n

" noremap! aoa !
" noremap! aor @
" noremap! aos #
" noremap! aot $
" noremap! aod %
" noremap! aoh ^
" noremap! aon &
" noremap! aoe *
" noremap! aoi (
" noremap! aoo )
" noremap! <M-l> ()<left>
" noremap! <M-u> []<left>
" noremap! <M-y> <end>{}<left>
" noremap! <A-S-y> {}<left>

noremap!  <Esc>

" }}}

